package router

import (
	"go_final/mxshop_api/userop_web/api/address"
	"go_final/mxshop_api/userop_web/api/message"
	"go_final/mxshop_api/userop_web/api/user_fav"
	middlewares "go_final/mxshop_api/userop_web/middleware"

	"github.com/gin-gonic/gin"
)

func InitUseropRouter(Router *gin.RouterGroup) {
	AddressRouter := Router.Group("address").Use(middlewares.JWTAuth())

	{
		AddressRouter.GET("", address.List)
		AddressRouter.POST("", address.Add)
		AddressRouter.DELETE("/:id", address.Delete)
		AddressRouter.PATCH("/:id", address.Update)
	}

	MessageRouter := Router.Group("message")
	{
		MessageRouter.GET("", middlewares.JWTAuth(), message.List) // 用于查看用户自己的留言
		MessageRouter.POST("", middlewares.JWTAuth(), message.Create)
	}

	UserFavRouter := Router.Group("userfav").Use(middlewares.JWTAuth())
	{
		UserFavRouter.GET("", user_fav.List) // 用户的收藏列表
		UserFavRouter.POST("/:id", user_fav.Add)
		UserFavRouter.DELETE("/:id", user_fav.Delete)
		UserFavRouter.GET("/:id", user_fav.Detail)
	}
}
